<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Biblioteca Pessoal</title>
</head>
<body>
	<f:view>
		<h2>
			Resultado de busca para
			<h:outputText value="#{livroMB.query}"></h:outputText>
			(<h:outputText value="#{usuarioMB.usuario.nome}"></h:outputText>)
		</h2>

		<h:form>
			<h:inputText value="#{livroMB.query}"></h:inputText>
			<h:commandButton value="Buscar livro por título ou nome de autor"
				action="#{livroMB.busca}" />
		</h:form>

		<br />

		<h:dataTable border="1" value="#{livroMB.livrosDaBusca}" var="l" rendered="#{livroMB.temResultadosDeBusca}">
			<h:column>
				<f:facet name="header">
					<h:outputText value="Nome do livro"></h:outputText>
				</f:facet>
				<h:outputText value="#{l.titulo}"></h:outputText>
			</h:column>
			<h:column>
				<f:facet name="header">
					<h:outputText value="ISBN"></h:outputText>
				</f:facet>
				<h:outputText value="#{l.isbn}"></h:outputText>
			</h:column>
			<h:column>
				<f:facet name="header">
					<h:outputText value="Ano de publicação"></h:outputText>
				</f:facet>
				<h:outputText value="#{l.anoPub}"></h:outputText>
			</h:column>
			<h:column>
				<f:facet name="header">
					<h:outputText value="Usuário"></h:outputText>
				</f:facet>
				<h:outputText value="#{l.usuario.nome}"></h:outputText>
			</h:column>
			<h:column>
				<f:facet name="header">
					<h:outputText value="Autores"></h:outputText>
				</f:facet>
				<h:outputText value="#{l.listaAutores}"></h:outputText>
			</h:column>
			
		</h:dataTable>
		
		<h:outputText rendered="#{livroMB.naoTemResultadosDeBusca}" value="Nenhum resultado foi encontrado para a sua busca"></h:outputText>

		<br />

		<h:form>
			<h:commandButton value="Todos os livros"
				action="biblioteca.jsp?faces-redirect=true"></h:commandButton>
		</h:form>
	</f:view>
</body>
</html>